<template>
  <div class="home">
    <Header />
    <info :getInfo="getInfo" />
    <CaseNum :caseNumData="caseNumData" />
    <Map />
    <MySwiper />
    <Travel />
    <News :newsData="newsData" />
  </div>
</template>

<script>
import api from '../api'
import Header from '../components/Header'
import info from '../components/info'
import CaseNum from '../components/CaseNum'
import Map from '../components/Map'
import MySwiper from '../components/MySwiper'
import Travel from '../components/Travel'
import News from '../components/News'

export default {
  name: 'Home',
  components: {
    Header,
    info,
    CaseNum,
    Map,
    MySwiper,
    Travel,
    News,
  },
  data(){
    return {
      getInfo:{
        note1:'',
        note2:'',
        note3:'',
        remark1:'',
        remark2:'',
        remark3:''
      },
      caseNumData:{
        currentConfirmedCount:'',
        confirmedCount:'',
        suspectedCount:'',
        curedCount:'',
        deadCount:'',
        seriousCount:'',
        suspectedIncr:'',
        currentConfirmedIncr:'',
        confirmedIncr:'',
        curedIncr:'',
        deadIncr:'',
        seriousIncr:'',
        modifyTime:''
      },
      newsData:{
        pubDateStr:[],
        title:[],
        summary:[],
        sourceUrl:[],
      }
    }
  },
  mounted(){
    api.getNcov({
      key:'75ec2a2f68c95935e305c3051b0a328a'
    })
    .then(res=>{
      // console.log(res.data);
      if (res.status === 200){
        var desc = res.data.newslist[0].desc;
        var news=res.data.newslist[0].news;
        this.getInfo.note1 = desc.note1
        this.getInfo.note2 = desc.note2
        this.getInfo.note3 = desc.note3
        this.getInfo.remark1 = desc.remark1
        this.getInfo.remark2 = desc.remark2
        this.getInfo.remark3 = desc.remark3
        // caseNumData
        this.caseNumData.modifyTime = desc.modifyTime
        this.caseNumData.currentConfirmedCount = desc.currentConfirmedCount
        this.caseNumData.confirmedCount = desc.confirmedCount
        this.caseNumData.suspectedCount = desc.suspectedCount
        this.caseNumData.curedCount = desc.curedCount
        this.caseNumData.deadCount = desc.deadCount
        this.caseNumData.seriousCount = desc.seriousCount
        this.caseNumData.suspectedIncr = desc.suspectedIncr
        this.caseNumData.currentConfirmedIncr = desc.currentConfirmedIncr
        this.caseNumData.confirmedIncr = desc.confirmedIncr
        this.caseNumData.curedIncr = desc.curedIncr
        this.caseNumData.deadIncr = desc.deadIncr
        this.caseNumData.seriousIncr = desc.seriousIncr
        //newsData
        this.newsData.pubDateStr[0]=news[0].pubDateStr
        this.newsData.title[0]=news[0].title
        this.newsData.summary[0]=news[0].summary
        this.newsData.sourceUrl[0]=news[0].sourceUrl
        this.newsData.pubDateStr[1]=news[1].pubDateStr
        this.newsData.title[1]=news[1].title
        this.newsData.summary[1]=news[1].summary
        this.newsData.sourceUrl[1]=news[1].sourceUrl
        this.newsData.pubDateStr[2]=news[2].pubDateStr
        this.newsData.title[2]=news[2].title
        this.newsData.summary[2]=news[2].summary
        this.newsData.sourceUrl[2]=news[2].sourceUrl
        this.newsData.pubDateStr[3]=news[3].pubDateStr
        this.newsData.title[3]=news[3].title
        this.newsData.summary[3]=news[3].summary
        this.newsData.sourceUrl[3]=news[3].sourceUrl
        this.newsData.pubDateStr[4]=news[4].pubDateStr
        this.newsData.title[4]=news[4].title
        this.newsData.summary[4]=news[4].summary
        this.newsData.sourceUrl[4]=news[4].sourceUrl
        console.log(this.newsData)
      }
    })
    .catch((error)=>{});
  }
};
</script>
